home *** CD-ROM | disk | FTP | other *** search
/ PCGUIA 127 / PC Guia 127.iso / Software / Utils / GParted Live CD / Bin / gparted-livecd-0.2.2.iso / usr_sqfs / bin / lesspipe.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2004-02-14  |  2.8 KB  |  65 lines

  1. #!/bin/sh
  2. #
  3. # Copyright 1997, 1998, 1999, 2000 Patrick Volkerding, Moorhead, Minnesota USA
  4. # Copyright 2001, 2002 Slackware Linux, Inc, Concord, CA, USA
  5. # All rights reserved.
  6. #
  7. # Redistribution and use of this script, with or without modification, is
  8. # permitted provided that the following conditions are met:
  9. #
  10. # 1. Redistributions of this script must retain the above copyright
  11. #    notice, this list of conditions and the following disclaimer.
  12. #
  13. #  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
  14. #  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  15. #  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
  16. #  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. #  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  18. #  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  19. #  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  20. #  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  21. #  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  22. #  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. #
  24.  
  25. # This is a preprocessor for 'less'.  It is used when this environment
  26. # variable is set:   LESSOPEN="|lesspipe.sh %s"
  27.  
  28. lesspipe() {
  29.   case "$1" in
  30.   *.tar) tar tvvf "$1" 2>/dev/null ;; # View contents of .tar and .tgz files
  31.   *.tgz) tar tzvvf "$1" 2>/dev/null ;;
  32.   *.tar.gz) tar tzvvf "$1" 2>/dev/null ;;
  33.   *.tar.Z) tar tzvvf "$1" 2>/dev/null ;;
  34.   *.tar.z) tar tzvvf "$1" 2>/dev/null ;;
  35.   *.tar.bz2) tar tjvvf "$1" 2>/dev/null ;;
  36.   *.Z) gzip -dc "$1" 2>/dev/null ;; # View compressed files correctly
  37.   *.z) gzip -dc "$1" 2>/dev/null ;;
  38.   *.zip) unzip -l "$1" 2>/dev/null ;;
  39.   *.rpm) rpm -qpvl "$1" 2>/dev/null ;;
  40.   *.1|*.2|*.3|*.4|*.5|*.6|*.7|*.8|*.9|*.n|*.man) # *roff src?
  41.     if file -L "$1" | grep roff 1> /dev/null ; then
  42.       nroff -S -mandoc "$1"
  43.     fi ;;
  44.   *.1.gz|*.2.gz|*.3.gz|*.4.gz|*.5.gz|*.6.gz|*.7.gz|*.8.gz|*.9.gz|*.n.gz|*.man.gz) # compressed *roff src?
  45.     if gzip -dc "$1" | file - | grep roff 1> /dev/null ; then
  46.       gzip -dc "$1" | nroff -S -mandoc -
  47.     fi ;;
  48.   *.1.bz2|*.2.bz2|*.3.bz2|*.4.bz2|*.5.bz2|*.6.bz2|*.7.bz2|*.8.bz2|*.9.bz2|*.n.bz2|*.man.bz2) # compressed *roff src?
  49.     if bzip2 -dc "$1" | file - | grep roff 1> /dev/null ; then
  50.       bzip2 -dc "$1" | nroff -S -mandoc -
  51.     fi ;;
  52.   *.gz) gzip -dc "$1"  2>/dev/null ;;
  53.   *.bz2) bzip2 -dc "$1" 2>/dev/null ;;
  54. #  *) FILE=`file -L "$1"` ; # Check to see if binary, if so -- view with 'strings'
  55. #    FILE1=`echo $FILE | cut -d ' ' -f 2`
  56. #    FILE2=`echo $FILE | cut -d ' ' -f 3`
  57. #    if [ "$FILE1" = "Linux/i386" -o "$FILE2" = "Linux/i386" \
  58. #         -o "$FILE1" = "ELF" -o "$FILE2" = "ELF" ]; then
  59. #      strings "$1"
  60. #    fi ;;
  61.   esac
  62. }
  63.  
  64. lesspipe "$1"
  65.